package com.eddy.mapper;

import com.eddy.entity.MainMenu;
import com.eddy.entity.SubjectMenu;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface MenuMapper {
    @Select("SELECT * FROM MainMenu")
    @Results({
            @Result(property = "id", column = "id"),
            @Result(property = "subList", column = "id", many = @Many(select = "com.eddy.mapper.MenuMapper.getSubjectMenus"))
    })
    List<MainMenu> getMainMenus();

    @Select("SELECT * FROM SubjectMenu WHERE MainId = #{mainId}")
    List<SubjectMenu> getSubjectMenus(@Param("mainId") int mainId);
}
